package com.sxj.corejava.code11_io.字符流;

import java.io.*;

/**
 * @author 石小俊
 */
public class Test01_文件字符流 {

    public static void main(String[] args) {
        try (
                Reader reader = new FileReader("hello.txt");
                Writer writer = new FileWriter("a.txt")
        ) {
            // 每次读取一个字符
//            System.out.println((char)reader.read());
            char[] c = new char[100];
            int i = -1;
            while ((i = reader.read(c)) != -1) {
//                System.out.println(new String(c, 0, i));
                writer.write(c, 0, i);
            }
        } catch (FileNotFoundException e) {
            throw new RuntimeException(e);
        } catch (IOException e) {
            throw new RuntimeException(e);
        }
    }

}
